#!/usr/bin/env python3
# coding:utf-8

class stack:
    def __init__(self,capacity=0):
        self.capacity = capacity
        self.stack = []
    
    def is_full(self):
        return len(self.stack) == self.capacity

    def is_empty(self):
        return len(self.stack) == 0

    def push(self,value):
        if self.is_full():
            raise Exception("stack is full")
        self.stack.append(value)
    
    def pop(self):
        if self.is_empty():
            raise Exception("stack is empty")
        self.stack.pop()

    def peek(self):
        if self.is_empty():
            raise Exception("stack is empty")
        return self.stack[-1]
    
    def show(self):
        print(self.stack)

if __name__ == '__main__':
    s = stack(5)
    s.push(1)
    s.push(2)
    s.push(3)
    s.push(4)
    s.push(5)
    print(s.peek())
    s.pop()
    print(s.peek())
    s.show()